package com.hb.trade.server.project.calibration.manager;

import cn.hutool.core.collection.CollUtil;
import com.hb.core.pojo.project.calibration.dto.BidWinResultDTO;
import com.hb.core.pojo.project.calibration.dto.BidWinResultSupplyDTO;
import com.hb.core.pojo.project.calibration.entity.BidWinResultSupply;
import com.hb.core.pojo.project.deal.entity.BidCandidateSupplier;

import java.util.List;

/**
 * describe:
 *  中标结果公示/公告表
 * @author zhongdl
 * @date 2021/12/20
 */
public class BidWinResultManager extends BidWinResultDTO {

    public List<BidWinResultSupply> listConversionSuccessful() {
        Long id = this.getId();
        List<BidWinResultSupplyDTO> successfulNoticeSupplyDTOList = this.getSuccessfulNoticeSupplyList();
        List<BidWinResultSupply> successfulNoticeSupplyList = CollUtil.list(false);
        for (BidWinResultSupplyDTO successfulNoticeSupplyDTO : successfulNoticeSupplyDTOList) {
            successfulNoticeSupplyDTO.setWinResultId(id);
            BidWinResultSupply successfulNoticeSupply = successfulNoticeSupplyDTO.to(BidWinResultSupply.class);
            if (successfulNoticeSupply.getId() == null) {
                successfulNoticeSupply.buildBaseData(1);
            }
            successfulNoticeSupplyList.add(successfulNoticeSupply);
        }
        return successfulNoticeSupplyList;
    }

    public static List<BidWinResultSupplyDTO> bidCandidateSupplierChange(List<BidCandidateSupplier> bidCandidateSuppliers) {
        List<BidWinResultSupplyDTO> list = CollUtil.list(false);
        if (CollUtil.isEmpty(bidCandidateSuppliers)) {
            return list;
        }
        for (BidCandidateSupplier bidCandidateSupplier : bidCandidateSuppliers) {
            BidWinResultSupplyDTO successfulNotice = new BidWinResultSupplyDTO();
            bidCandidateSupplier.to(successfulNotice);
            list.add(successfulNotice);
        }
        return list;
    }
}
